import { Component, ViewEncapsulation, ViewChild, OnInit, AfterViewInit } from '@angular/core';
import { Router } from '@angular/router';

@Component({
  selector: 'mobile-home-page',
  templateUrl: './mobile.home.page.html',
  styleUrls: ['./mobile.home.page.less'],
})
export class MobileHomeComponent implements OnInit, AfterViewInit {
  log = '';
  waitApprove: string;
  waitWo: string;
  total = 0;
  options: any = {
    onInit: () => {
      setTimeout(() => { this.log = '初始化完成'; });
    },
    onSlideChangeEnd: (swiper: any) => {
      setTimeout(() => { this.log = `移动至第 ${swiper.realIndex + 1} 张`; });
    }
  };

  swiperOptions: any = {
    effect: 'fade', spaceBetween: 30, autoplay: 2000
    // loop: true,
    // speed: 400,
    // autoplay: 3000
  };

  swiperImages: any = [
    { url: 'http://pic29.photophoto.cn/20131204/0034034499213463_b.jpg' },
    { url: 'http://img.taopic.com/uploads/allimg/110202/292-11020203332568.jpg' },
    { url: 'http://img.wanchezhijia.com/A/2015/5/6/9/48/c6344b4e-07a8-48a4-b5b9-b08cc7269d62.jpg' },
    { url: 'http://www.taopic.com/uploads/allimg/110910/2518-11091022301758.jpg' }
  ];
  images: any[] = [
    { url: './assets/images/swiper-1.png', title: '标题1' },
    { url: './assets/images/swiper-2.png', title: '标题2' },
    { url: './assets/images/swiper-3.png', title: '标题3' }
  ];

  commonUseMenus = [];

  commonMenus = [];


  empSelfHelpMenus = [
    { menuCode: 'GRDA', menuName: '个人档案', iconSrc: 'assets/mobile/icon/个人档案二.png', badgeNum: '0' },
    { menuCode: 'XZD', menuName: '薪资单', iconSrc: 'assets/mobile/icon/钱包.png', badgeNum: '0' },
    { menuCode: 'KQQR', menuName: '考勤确认', iconSrc: 'assets/mobile/icon/考勤确认.png', badgeNum: '0' },
    { menuCode: 'FQGD', menuName: '发起工单', iconSrc: 'assets/mobile/icon/myWo.png', badgeNum: '0' },
    { menuCode: 'JQSQ', menuName: '假勤申请', iconSrc: 'assets/mobile/icon/假勤申请.png', badgeNum: '0' },
    { menuCode: 'LCSQ', menuName: '流程申请', iconSrc: 'assets/mobile/icon/流程申请.png', badgeNum: '0' },
    { menuCode: 'DSPLC', menuName: '待审批流程', iconSrc: 'assets/mobile/icon/待审批流程.png', badgeNum: '0' },
    { menuCode: 'DCLGD', menuName: '待处理工单', iconSrc: 'assets/mobile/icon/告警待处理.png', badgeNum: '0' },
    // { menuCode: 'DK', menuName: '打卡', iconSrc: 'https://cipchk.github.io/ngx-weui/images/icon_tabbar.png' }
  ];

  mgrSelfHelpMenus = [
    { menuCode: 'WDXS', menuName: '我的下属', iconSrc: 'assets/mobile/icon/我的下属.png' }
  ];

  constructor(
    private router: Router
  ) { }

  ngOnInit() {
    // window.localStorage.setItem("isChecked", 'UnChecked');
    if (window.localStorage.getItem('commonUseMenus')) {
      this.commonMenus = JSON.parse(window.localStorage.getItem('commonUseMenus'));
      console.log(this.commonMenus);
      for (let i = 0; i < this.commonMenus.length; i++) {
        const item = {
          menuCode: this.commonMenus[i].menuCode,
          menuName: this.commonMenus[i].menuName,
          iconSrc: this.commonMenus[i].iconSrc,
          badgeNum: '0',
        };
        this.commonUseMenus.push(item);
      }
      this.commonUseMenus.push(
        { menuCode: 'TJ', menuName: '添加', iconSrc: 'assets/mobile/icon/添加.png', badgeNum: '0' }
      );
      console.log(this.commonUseMenus);
    } else {
      this.commonUseMenus = [
        { menuCode: 'TJ', menuName: '添加', iconSrc: 'assets/mobile/icon/添加.png', badgeNum: '0' }
      ];
    }
  }

  ngAfterViewInit() {

  }

  onClickMenuItem(menu: any) {
  }
}
